package com.sec.bnjey.global;

import android.content.Context;
import android.content.SharedPreferences;

public class IKPreferences {
	private static String preferences_name = "IKPreferences.Main";
	private static volatile IKPreferences preferences;

	final public static String IS_BLUETOOTH_ENABLED = "IS_BLUETOOTH_ENABLED";

	final public static String SELECTED_CAR_INDEX = "SELECTED_CAR_INDEX";

	SharedPreferences mSharedPreferences;

	private IKPreferences(Context context) {
		mSharedPreferences = context.getSharedPreferences(preferences_name,
				Context.MODE_PRIVATE);
	}

	public static IKPreferences getPreferences() {
		if (preferences == null) {
			synchronized (IKPreferences.class) {
				if (preferences == null) {
					preferences = new IKPreferences(
							GlobalApplication.getAppContext());
				}
			}
		}
		return preferences;
	}

	public void setBluetoothEnabled(boolean isEnabled) {
		mSharedPreferences.edit().putBoolean(IS_BLUETOOTH_ENABLED, isEnabled)
				.commit();
	}

	public boolean isBluetoothEnabled() {
		return mSharedPreferences.getBoolean(IS_BLUETOOTH_ENABLED, false);
	}

	public void setSelectedCarIndex(int index) {
		mSharedPreferences.edit().putInt(SELECTED_CAR_INDEX, index).commit();
	}

	public int getSelectedCarIndex() {
		return mSharedPreferences.getInt(SELECTED_CAR_INDEX, -1);
	}

}
